fix: infer table columns from documents for schema-less collections - #63
Conversation
Collections with model: [] showed blank table views even when documents existed. Column definitions are now derived from the first document keys when model is empty. View toggles visible for any collection with documents. Boolean values render as true/false instead of blank.
|
@KushagraJaiswar02 is attempting to deploy a commit to the Yash Pouranik's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughTwo components in the web-dashboard receive updates to improve robustness and conditional rendering. CollectionTable.jsx now defensively handles missing active collection state and infers column types from data when model definitions unavailable. Database.jsx conditionally displays the view-mode toggle only when schema fields or data exist. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request enhances the CollectionTable component by allowing it to infer column definitions directly from the data when a collection model is unavailable. It also refines cell rendering to handle null or undefined values more gracefully and ensures the view toggle in the Database page is only displayed when relevant data exists. Review feedback highlights a potential runtime error when accessing the first data element for column inference and suggests moving static helper functions outside the useMemo hook to improve performance and code organization.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/web-dashboard/src/components/CollectionTable.jsx (1)
91-103: Consider lifting inferred fields out ofCollectionTable.Right now only the table knows about these derived keys.
apps/web-dashboard/src/pages/Database.jsxstill builds the sort/filter selectors fromactiveCollection?.modelat Lines 481-483 and 516-518, so schema-less collections can show columns that the query UI cannot target.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web-dashboard/src/components/CollectionTable.jsx` around lines 91 - 103, The table-only inference of schema (the baseColumns logic in CollectionTable that uses inferType) causes the query UI to miss derived fields; extract that inference into a shared helper (e.g., inferModelFromData(data, SYSTEM_FIELDS) that returns [{key,type},...]) and replace the inline mapping in CollectionTable (baseColumns) to call this helper, then update the query UI code that builds selectors (the places referencing activeCollection?.model) to fall back to inferModelFromData(data, SYSTEM_FIELDS) when activeCollection.model is empty so both components use the same derived model.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web-dashboard/src/components/CollectionTable.jsx`:
- Around line 91-103: baseColumns currently infers schema-less columns from only
data[0], which loses keys present in later rows; update the logic that builds
the fallback columns (the ternary branch that uses Object.entries(data[0])) to
iterate over all rows in data, collect the union of keys excluding
SYSTEM_FIELDS, then map those keys to column objects using inferType (prefer the
first non-undefined/non-null value encountered for type inference). Keep the
existing activeCollection.model branch unchanged, ensure deterministic ordering
(e.g., sort keys) so columns don't jump when pagination/sorting changes, and
reference baseColumns, SYSTEM_FIELDS, inferType and data when making the change.
---
Nitpick comments:
In `@apps/web-dashboard/src/components/CollectionTable.jsx`:
- Around line 91-103: The table-only inference of schema (the baseColumns logic
in CollectionTable that uses inferType) causes the query UI to miss derived
fields; extract that inference into a shared helper (e.g.,
inferModelFromData(data, SYSTEM_FIELDS) that returns [{key,type},...]) and
replace the inline mapping in CollectionTable (baseColumns) to call this helper,
then update the query UI code that builds selectors (the places referencing
activeCollection?.model) to fall back to inferModelFromData(data, SYSTEM_FIELDS)
when activeCollection.model is empty so both components use the same derived
model.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d499e955-0fde-4ff5-bd5d-497b23061df8
📒 Files selected for processing (2)
apps/web-dashboard/src/components/CollectionTable.jsxapps/web-dashboard/src/pages/Database.jsx
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Fixes blank/limited table rendering in the web dashboard for schema-less collections (model: []) by deriving table columns from document data and improving display behavior when documents exist.
Changes:
- Show view-mode toggles when either a schema exists or documents exist.
- Infer table columns from the first document’s keys when
activeCollection.modelis empty. - Improve cell rendering for null/undefined and boolean values.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/web-dashboard/src/pages/Database.jsx | Conditionally renders the view toggle based on presence of schema fields or documents. |
| apps/web-dashboard/src/components/CollectionTable.jsx | Adds schema-less column inference and improves cell rendering for booleans and null/undefined values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
yash-pouranik
left a comment
There was a problem hiding this comment.
fix suggested changes, and will merge
Collections with model: [] showed blank table views even when documents existed. Column definitions are now derived from the first document keys when model is empty. View toggles visible for any collection with documents. Boolean values render as true/false instead of blank.
🚀 Pull Request Description
Fixes # (issue number)
🛠️ Type of Change
🧪 Testing & Validation
Backend Verification:
npm testin thebackend/directory and all tests passed.Frontend Verification:
npm run lintin thefrontend/directory.📸 Screenshots / Recordings (Optional)
✅ Checklist
Built with ❤️ for urBackend.
Summary by CodeRabbit
Release Notes